package com.hex.ds.hdrs.period.task.converter;

import com.hex.ds.hdrs.common.utils.BaseUtil;
import com.hex.ds.hdrs.common.utils.HdrsDateUtil;
import com.hex.ds.hdrs.period.task.po.MutexPool;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(componentModel = "spring", imports = {BaseUtil.class, HdrsDateUtil.class})
public interface IMutexPoolConverter {

    @Mapping(target = "pkId", expression = "java(BaseUtil.getPkId())")
    @Mapping(target = "appCode", source = "appCode")
    @Mapping(target = "poolType", source = "poolType")
    @Mapping(target = "taskCodes", source = "taskCodes")
    @Mapping(target = "crtTs", expression = "java(HdrsDateUtil.getCurrentTime())")
    @Mapping(target = "crtUser", expression = "java(BaseUtil.getUserId())")
    @Mapping(target = "upTs", expression = "java(HdrsDateUtil.getCurrentTime())")
    @Mapping(target = "upUser", expression = "java(BaseUtil.getUserId())")
    MutexPool toMutexPool(String appCode, String taskCodes, String groupCode, String poolType);

    @Mapping(target = "taskCodes", source = "taskCodes")
    @Mapping(target = "upTs", expression = "java(HdrsDateUtil.getCurrentTime())")
    @Mapping(target = "upUser", expression = "java(BaseUtil.getUserId())")
    MutexPool toMutexPool(MutexPool mutexPool, String taskCodes);
}
